package com.crealth.crmserver;

import org.apache.log4j.Logger;
import com.crealth.handler.ClientMsgHandler;
import com.crealth.handler.RequestMsgQueue;
import com.crealth.handler.ResponseMsgQueue;
import com.crealth.msg.NetMessageData;
import com.crealth.utils.Utils;

public class RequestMsgThread extends Thread {
	private static Logger logger = Logger.getLogger("running_log");
	//private static Logger errorLog = Logger.getLogger("error_log");

	@Override
    public void run() {
		NetMessageData revData = RequestMsgQueue.getRequestMsg();
		if (revData == null) {
			return;
		}
		int userID = revData.getUserID();
		NetMessageData resData = ClientMsgHandler.msgHandler(revData);
		if (resData == null) {
			return;
		}
		resData.setUserID(userID);
		int cmd = revData.getMsgCmd();
		if (resData != null) {
			if (Utils.isWindows()) {
				logger.info("send request cmd:" + cmd);
			}
			resData.setMsgCmd(cmd);
			/*
			IoSession session = SessionManager.getUserSessionByID(userID);
			if (session != null && session.isConnected()) {
				session.write(resData);
			}
			*/
			ResponseMsgQueue.addMsgToQueue(resData);
		}
	}
	
	
}
